package com.net.test;

import com.hos.utile.DLog;
import com.hos.utile.JsonUtile;
import com.net.retrofits.common.RequestBack;
import com.net.retrofits.use.manager.push.HWPushManager;
import com.net.retrofits.use.req.push.AndroidConfig;
import com.net.retrofits.use.req.push.AndroidNotification;
import com.net.retrofits.use.req.push.BadgeNotification;
import com.net.retrofits.use.req.push.ClickAction;
import com.net.retrofits.use.req.push.HWMsg;
import com.net.retrofits.use.req.push.HWPushReq;

/**
 * Created by Administrator on 2020/10/19 0019.
 */
public class HWPush implements RequestBack {
    private HWPushManager pushManager;


    private String hwAppid = "101765473";

    public void onReq() {
        if (pushManager == null) {
            pushManager = new HWPushManager(this);
            pushManager.setAppId(hwAppid);
            pushManager.setToken(tkoken1);
        }
        pushManager.setReqData(setReqData());
        pushManager.doRequest();
    }

    public void test() {
        String json = JsonUtile.obj2Json(setReqData());
        DLog.e(json);
    }
    String tkoken1 = "HW_AIc1M7hyWpqqUIHrphEH9yiBGpNoJ1fiW1IS4sMW3pHk2if4JLBqYevlTGqQp-hm4QS7wx8_rkscfgbrYmZBv8REHPUrJNWm46x6nBOl549Oa8E9uo2_YQQq-gUMsXGT5A";

    private HWPushReq setReqData() {
        BadgeNotification bn = new BadgeNotification();
        bn.add_num = 1;
        bn.set_num = 80;
        bn.badgeClass =  "com.app.ui.activity.launch.LaunchActivity";
        //
        AndroidNotification an = new AndroidNotification();
        an.title = "推送测试";
        an.body = "推送测试123456";
        an.badge = bn;
        an.click_action = new ClickAction();
        //
        AndroidConfig ac = new AndroidConfig();
        ac.notification = an;
        //
        HWMsg hwMsg = new HWMsg();
        hwMsg.android = ac;
         hwMsg.token = new String[]{tkoken1};
        //
        HWPushReq req = new HWPushReq();
        req.message = hwMsg;

        return req;
    }

    @Override
    public void onBack(int what, Object obj, String msg, String other) {
        DLog.e("手打消息了");
    }

    @Override
    public void onBackProgress(int what, String url, String filePath, long currentLength, long totalLength) {

    }
}
